﻿using System;
using System.Runtime.Serialization;

namespace LiSA_Server.Base.NHibernate.Models
{
    [DataContract]
    public class Entity
    {
        #region Public Properties

        /// <summary>
        /// Gets or sets the created date time.
        /// </summary>
        [DataMember]
        public virtual DateTime? CreatedDateTime { get; set; }

        /// <summary>
        /// Gets or sets the ID of the Entity.
        /// </summary>
        [DataMember]
        public virtual Guid ID { get; set; }

        /// <summary>
        /// Gets or sets the version.
        /// </summary>
        [DataMember]
        public virtual int Version { get; set; }

        #endregion

        #region Public Methods and Operators

        /// <summary>
        /// The equals.
        /// </summary>
        /// <param name="obj">
        /// The obj.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public override bool Equals(object obj)
        {
            var et = obj as Entity;

            return et != null && this.ID.Equals(et.ID);
        }

        /// <summary>
        /// The get hash code.
        /// </summary>
        /// <returns>
        /// The <see cref="int"/>.
        /// </returns>
        public override int GetHashCode()
        {
            return this.ID.GetHashCode();
        }

        #endregion
    }
}